﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MVCms.Core.DataAccess;
using MVCms.Core.Developers;

namespace MVCms.Core.Entities
{
    [Serializable]
    public class PageModule : BaseEntity
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PageModule"/> class.
        /// </summary>
        public PageModule()
        {
            this.ModuleRoles = new List<ModuleRole>();
        }

        /// <summary>
        /// Gets or sets the virtual page that this module belongs to
        /// </summary>
        /// <value>The virtual page.</value>
        public virtual VirtualPage VirtualPage { get; set; }
        /// <summary>
        /// Gets or sets the module.
        /// </summary>
        /// <value>The module.</value>
        public virtual PluginModule Module { get; set; }
        /// <summary>
        /// Gets or sets the panel name  where this plugin should be displayed.
        /// </summary>
        /// <value>The panel.</value>
        public virtual string Panel { get; set; }
        /// <summary>
        /// Gets or sets the position in accosiation with the other modules that this module needs to be displayed
        /// </summary>
        /// <value>The position.</value>
        public virtual int Position { get; set; }
        /// <summary>
        /// Gets or sets the title of the module.
        /// </summary>
        /// <value>The title.</value>
        public virtual string Title { get; set; }
        /// <summary>
        /// Gets or sets the roles that's allowed to view this plugin
        /// </summary>
        /// <value>The module roles.</value>
        public virtual IList<ModuleRole> ModuleRoles { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="PageModule"/> should be displayed to the currently logged in user
        /// </summary>
        /// <value><c>true</c> if display; otherwise, <c>false</c>.</value>
        [McContext.IgnoreAttribute]
        public virtual bool Display { get; set; }
        /// <summary>
        /// Gets the client ID.
        /// </summary>
        /// <value>The client ID.</value>
        [McContext.IgnoreAttribute]
        public virtual string ClientID
        {
            get
            {
                return string.Format("{0}_{1}_{2}", this.Position, this.Module.Controller, this.Module.Action);
            }
        }
    }
}
